home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / checkbox / install / postinst < prev   
Text File  |  2009-11-05  |  3KB  |  84 lines

  1. package=`basename $0 .postinst`
  2. config="/etc/checkbox.d/$package.ini"
  3.  
  4. patch_configuration()
  5. {
  6.     version="$1"
  7.     previous_version=""
  8.     base_package=`echo $package | sed -e 's/hwtest/checkbox/' -e 's/\(-cli\|-gtk\)//'`
  9.  
  10.     while [ -n "$version" ]; do
  11.         patch_file=""
  12.         patch_directory="/usr/share/$base_package/patches"
  13.         [ ! -d "$patch_directory" ] && break
  14.  
  15.         # Sort patches using dpkg --compare-versions
  16.         for temp_file in `find $patch_directory -type f`; do
  17.             [ -n "$patch_file" ] \
  18.                 && patch_version=`basename $patch_file` \
  19.                 || patch_version=""
  20.             temp_version=`basename $temp_file`
  21.             if dpkg --compare-versions $temp_version lt-nl "$patch_version" && \
  22.                dpkg --compare-versions $temp_version gt "$previous_version"; then
  23.                 patch_file=$temp_file
  24.             fi
  25.         done
  26.  
  27.         # If patch file is empty, all versions have been compared
  28.         [ -z "$patch_file" ] && break
  29.  
  30.         # Apply the patch file if it is less than the given version
  31.         patch_version=`basename $patch_file`
  32.         if dpkg --compare-versions $version lt $patch_version; then
  33.             # Package was renamed from hwtest to checkbox
  34.             dpkg --compare-versions $patch_version lt "0.1-ubuntu13" \
  35.                 && patch_package=`echo $package | sed 's/checkbox/hwtest/'` \
  36.                 || patch_package=`echo $package | sed 's/hwtest/checkbox/'`
  37.             $patch_file $patch_package
  38.         fi
  39.  
  40.         previous_version=`basename $patch_file`
  41.     done
  42. }
  43.  
  44. update_configuration()
  45. {
  46.     base_package=`echo $package | cut -d '-' -f '1'`
  47.  
  48.     if [ "$base_package" != "hwtest" ]; then
  49.         # Create a temporary file to generate the suggested
  50.         # configuration file.
  51.         tempfile=`tempfile -m 0644 -p checkbox`
  52.  
  53.         # Update the temporary file with preseeded values.
  54.         /usr/share/checkbox/install/config --output=$tempfile $package
  55.  
  56.         # Clobber the old config file.
  57.         cp $tempfile $config
  58.  
  59.         # Now clear up the cruft.
  60.         rm -f $tempfile
  61.     fi
  62. }
  63.  
  64. case "$1" in
  65.     configure)
  66.         # Workaround python-support which doesn't remove packages
  67.         # under /usr/lib/python*
  68.         for support_dir in python2.4 python2.5; do
  69.             package_dir="/usr/lib/$support_dir/site-packages/$package"
  70.             [ -e "$package_dir" ] && rm -fr $package_dir
  71.         done
  72.  
  73.         # Patch and update configuration file
  74.         patch_configuration "$2"
  75.         update_configuration
  76.         ;;
  77.     abort-upgrade|abort-remove|abort-deconfigure)
  78.         ;;
  79.     *)
  80.         echo "$0: didn't understand being called with \`$1'" 1>&2
  81.         exit 0
  82.         ;;
  83. esac
  84.